package com.isyscore.handler;

import com.isyscore.constant.ResponseCode;
import com.isyscore.util.ResultUtil;
import com.isyscore.vo.ResponseVo;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: liuxq@isyscore.com
 * @Date: 2021-04-16 09:50:38
 * @Description: 用户未登录处理类
 */
@Component
public class UserAuthenticationEntryPointHandler implements AuthenticationEntryPoint {
    /**
     * 用户未登录返回结果
     */
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) {
        ResultUtil.responseJson(response, ResponseVo.fail(ResponseCode.UN_LOGIN));
    }
}
